import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

export default new Vuex.Store({
    state:{
        videoRecord:localStorage.getItem("videoRecord"),
        has:'1212',
        fid: '1212'
    },
    mutations:{
        addRecord(state,obj){
            /*let newArray = state.videoRecord;
                 if(!newArray){
                     if(obj.indexOf(newArray)<0){//没有重复项
                         if(newArray.length<10){
                             newArray.push(obj);
                         }else{
                             newArray.push(obj);
                             let arrays = newArray.splice(-10,10);//取后十位数据
                         }
                     }
                 }else{
                     newArray.push(obj);
                 }*/
             state.videoRecord = obj;
             return state.videoRecord;
        },
        delRecord(state,obj) {
            state.videoRecord = [];
        },
        upfid(state, fid) {
            state.fid = fid
        }
    },
    actions:{
        addFun(context,obj){
             context.commit("addRecord",obj);
        },
        delFun(context){
             context.commit("delRecord");
        },
        upfid(context, fid) {
           context.commit('addRecord',fid);//context.commit（'mutations方法名','参数'）

        }
    }
})

